import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ExploreContainerLocalFactory } from './explore/explore-container-factory';
import { IExploreContainer } from './explore/explore.defind';

@Component({
  selector: 'app-main',
  templateUrl: './main.component.html',
  styleUrls: ['./main.component.scss']
})
export class MainComponent implements OnInit {
  public localExport: IExploreContainer;
  constructor(private http: HttpClient) { }

  async ngOnInit() {
    this.localExport = ExploreContainerLocalFactory();
    await this.localExport.addExplores();
    this.localExport.setActive(0);
    this.localExport.addExplores();
    console.log(this.localExport);
    try {
      const ipc =  (<any>window).require('electron');
      console.log(ipc);
    } catch (error) {
      console.log(error)
    }
  }
  showVal(...val: any) {
    console.log(val);
  }
  optSize(val: number) {
    if(val > 1024*1024*1024) {
      return (val/1024/1024*1024).toFixed(2) + 'GB';
    }
    if(val > 1024*1024) {
      return (val/1024/1024).toFixed(2) + 'MB';
    }
    return val + 'KB';
  }
}
